import Mock from 'mockjs'

const userList = []
const userCount = 10

for (let i = 0; i < userCount; i++) {
  userList.push(Mock.mock({
    userId: '@increment',
    userName: '@cname(2, 3)',
    'account': /[a-z]{5,10}/,
    'state|1': ['0', '1'],
    'staffCode': /[Q][Y][0-9]{6}/,
    'sex|1': ['男', '女'],
    email: '@email',
    'phone': /^1[34578]\d{9}$/,
    orgName: '@ctitle(4,10)',
    lastLoginTime: '@datetime'
  }))
}

export default [
  {
    url: '/user/list',
    type: 'get',
    response: (req, res) => {
      return {
        code: 0,
        msg: '请求成功',
        data: {
          userList,
          'pageTotal|100-1000': 1000
        }
      }
    }
  },
  {
    url: '/user/modifyState',
    type: 'post',
    response: (req, res) => {
      return {
        code: 0,
        msg: '操作成功',
        data: {
          userList,
          'pageTotal|100-1000': 1000
        }
      }
    }
  },
  {
    url: '/user/add',
    type: 'post',
    response: (req, res) => {
      return {
        code: 0,
        msg: '添加成功',
        data: {
          userList,
          'pageTotal|100-1000': 1000
        }
      }
    }
  },
  {
    url: '/user/getById',
    type: 'get',
    response: (req, res) => {
      return {
        code: 0,
        msg: '操作成功',
        data: {
          userId: '@increment',
          userName: '@cname(2, 3)',
          'account': /[a-z]{5,10}/,
          'state|1': ['0', '1'],
          'staffCode': /[Q][Y][0-9]{6}/,
          'sex|1': ['男', '女'],
          email: '@email',
          'phone': /^1[34578]\d{9}$/,
          orgName: '@ctitle(4,10)',
          'password|100000-999999': 999999,
          lastLoginTime: '@datetime',
          roleIds: ['admin', 'editer']
        }
      }
    }
  },
  {
    url: '/user/delete',
    type: 'get',
    response: (req, res) => {
      return {
        code: 0,
        msg: '删除成功',
        data: {
          userList,
          'pageTotal|100-1000': 1000
        }
      }
    }
  },
  {
    url: '/user/export',
    type: 'post',
    response: (req, res) => {
      return {
        code: 0,
        msg: '导出成功',
        data: {}
      }
    }
  },
  {
    url: '/role/getPermission',
    type: 'get',
    response: (req, res) => {
      return {
        code: 0,
        msg: '操作成功',
        data: {}
      }
    }
  },
  {
    url: '/role/savePermission',
    type: 'post',
    response: (req, res) => {
      return {
        code: 0,
        msg: '操作成功',
        data: {}
      }
    }
  }
]
